<template>
  <div class="login">
    <h5 style="height: 35px;line-height: 35px; text-indent: 15px;background: #fff;">
      驾校通系统
      <img src="../assets/images/close.png" alt="" @click="close" style="width: 20px;margin: 0 13px;cursor: pointer;float: right;margin-top: 6px;" >
     </h5>
    <ul class="log-top">
      <li @click="overevent(0)" :class="{show:nowidx==0,next:next==0,prve:prve==0}">
          <div>
            <img src="../assets/images/loginJ.png" alt="">
            <span></span>
          </div>
          <span>Login</span>
          <b>登录</b>

      </li>

      <li @click="overevent(3)"  :class="{show:nowidx==3,next:next==3,prve:prve==3}">
          <div>
            <img src="../assets/images/images/logint_03.png" alt=""><span></span>
          </div>
          <span>ABOUT Service</span>
          <b>联系我们</b>
      </li>
    </ul>
    <dl>
      <dd v-show="nowidx==0" class="login-input">
        <h5>账号登陆</h5>
        <div><input type="text" v-model="data.username"></div>
        <div><input type="password" v-model="data.pass1"></div>
        <p>
          <label for="checkbox">
            <input type="checkbox" id="checkbox">
            记住密码
          </label>
         <router-link to="" style="color: red;pointer-events: none;" v-if="text">
            {{text}}
          </router-link >
        </p>
        <button @click="sub()">登录</button>
      </dd>

      <dd v-show="nowidx==3" class="serter">
        <ol>
          <li>
            <img src="../assets/images/logphone_03.png" alt="">
            <p>
              拨打24小时服务热线
              <small>24h Hotline</small>
            </p>
            <span>400-930-9930</span>
          </li>
          <li>
            <img src="../assets/images/logxin_03.png" alt="">
            <p>
              服务邮箱
              <small>Service Email</small>
            </p>
            <span>33665155@qq.com</span>
          </li>
          <li style="padding-top: 1rem;overflow: hidden;">
            <img src="../assets/images/logwei_03.png" alt="">
            <p>
              服务微信
              <small>Service Wechat</small>
            </p>
            <span>
              <img src="../assets/images/weierwei_03.png" alt="" style="margin-top: -2.5rem;">
            </span>
          </li>
        </ol>
      </dd>
    </dl>
    <img src="../assets/images/log-log_03.png" alt="">
  </div>
</template>

<script>
  export default {
    name: 'login',
    data() {
      return {
        data:{username:'',pass1:'',pass:''},
        next:1,
        prve:0,
        nowidx:0,
        text:false
      }
    },
    methods:{
      overevent(id){
        this.nowidx = id;
        this.next = id + 1;
        this.prve = id - 1;
      },
      close(){
        ipcRenderer.send('closeWin');
      },
      sub(){
        var _this = this;
        if(!this.data.username) return this.text = '用户名不能为空';
        if(!this.data.pass1) return this.text = '密码不能为空';
        this.getData({
          url:_this.$root.Url+'/login',
          json:{username:this.data.username,pass:this.md5(this.data.pass1)},
          type:'post',
          success:function(e){
            if(e.data.success){
              $cookies.set("userdata",e.data.lst,'0');
              // _this.$router.push('/index');
              ipcRenderer.send('index');
            }else{
              _this.confirm({title:'app提示',msg:e.data.info});
            }
          },
          error:function(){

          }
        });
      }
    },
    mounted() {
      // console.log(this.confirm())
      // console.log($cookies)
      var _this = this;
      $(window).click(function(e){
        if($(e.target).attr('class') != $('.newmenu p span').attr('class')){
          _this.menuid=-1;
        }
      })
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  @import "../assets/css/login.css";
</style>
